package com.village.friend.mapper;

import com.village.friend.entity.ActivityJoin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * <p>
 * 活动报名表 Mapper 接口
 * </p>
 *
 * @author yl
 * @since 2021-11-13
 */
@Mapper
public interface ActivityJoinMapper extends BaseMapper<ActivityJoin> {

    @Insert("insert into  activity_join(activity_id,user_id,user_id_join,is_join)  values (#{activityId},#{userId},#{userIdJoin},#{isJoin}) on  duplicate key update  is_join=#{isJoin},create_time=now(), update_time=now()")
    Integer insertOrUpdate(Integer activityId, Integer userId, Integer userIdJoin, Integer isJoin);

    @Insert("insert into  activity_join(activity_id,user_id,user_id_join,is_agree)  values (#{activityId},#{userId},#{userIdJoin},#{isAgree}) on  duplicate key update  is_agree=#{isAgree}, update_time=now()")
    Integer insertOrUpdateAgree(Integer activityId, Integer userId, Integer userIdJoin, Integer isAgree);


    List<ActivityJoin> getJoinList(Integer activityId, Integer offset, Integer limit);

    Integer getJoinCount(Integer id);
}
